<template>
  <div>
    <el-container style="height: 600px; border: 1px solid #eee">
      <!-- 侧边栏 -->
      <el-aside :width="asideWidth" style="background-color: #001529;height:600px;">
        <div style="height:60px; color: white; display: flex; align-items: center; justify-content: center" >
         <img src="@/assets/work.png" style="width: 40px; height: 40px;">
          <span style="margin-left: 5px;font-size: 20px"v-show="!this.isCollapsed">honey2024</span><!-- v-show="!this.isCollapsed"侧边栏收回的时候隐藏文字 -->
        </div>

        <el-menu :collapse="isCollapsed" :collapse-transition="false" :default-openeds="[]" background-color="#001529" text-color="#ffff" active-text-color="#fff">
          <el-submenu index="0">
            <template slot="title"><i class="el-icon-setting"></i><span v-show="!this.isCollapsed"> 首页</span></template>
            <el-menu-item-group>
              <el-menu-item index="1-0">
                <router-link to="/yemian/homepage" style="text-decoration: none;color: rgba(255,255,255,0.65);">首页</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>
          <el-submenu index="1">
            <template slot="title"><i class="el-icon-setting"></i><span v-show="!this.isCollapsed"> 系统管理</span></template>
            <el-menu-item-group>
              <el-menu-item index="1-1">
                <router-link to="/yemian/user" style="text-decoration: none;color: rgba(255,255,255,0.65);">用户管理</router-link>
              </el-menu-item>
              <el-menu-item index="1-2">
                <router-link to="/yemian/role" style="text-decoration: none;color: rgba(255,255,255,0.65);">角色管理</router-link>
              </el-menu-item>
              <el-menu-item index="1-3">
                <router-link to="/yemian/menu" style="text-decoration: none;color: rgba(255,255,255,0.65);">菜单管理</router-link>
              </el-menu-item>
              <el-menu-item index="1-4">
                <router-link to="/yemian/dictionaries" style="text-decoration: none;color: rgba(255,255,255,0.65);">字典管理</router-link>
              </el-menu-item>
            </el-menu-item-group>
          </el-submenu>

        </el-menu>
      </el-aside>

      <el-container>
        <!-- 头部 -->
        <el-header>
              <i class="el-icon-s-fold" style="width: 60px; height: 40px; margin-top: 20px" @click="handleCollapes"></i>
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item :to="{ path: '/yemian/user' }">用户管理</el-breadcrumb-item>
          </el-breadcrumb>

          <div style="flex: 1; width: 0; display: flex; align-items: center; justify-content: flex-end;" >
            <el-dropdown placement="bottom">
              <div style="display: flex; align-items: center; ">
                <img src="@/assets/work.png" alt="" style="width: 40px; height: 40px; border-radius: 30px; margin: 0 10px">
                <span>管理员</span>
              </div>

              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item>个人信息</el-dropdown-item>
                <el-dropdown-item>修改密码</el-dropdown-item>
                <el-dropdown-item @click.native="goToPage1">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </el-header>
        <!-- 子路由(身体) -->
        <el-main>
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>

export default {
  data() {

    //下拉框选择器
    return {
      input : "",
      // tableData: Array(20).fill(item),
      options: [
        {
          value: "选项1",
          value1: "选项1",
          label: "男",
        },
        {
          value: "选项2",
          value1: "选项2",
          label: "女",
        },
      ],
      value: "",
      isCollapsed : false,//不收缩或不收缩
      asideWidth : '200px',
      // user: JSON.parse(localStorage.getItem('honey-user') || '{}')//用来判断role字段是否为管理员，是管理员就全部显示功能
    };
  },
  methods: {
    handleCollapes(){
      this.isCollapsed = !this.isCollapsed
      this.asideWidth = this.isCollapsed ? '64px': '200px'
    },
    goToPage1() {
      sessionStorage.clear('true');//用于删除特定的存储项，true 应当替换为你想要删除的键名。

      this.$router.push('/login'); // 跳转到页面1，例如 /page1


    },
  }
};
</script>
<!-- 大页面 -->
<style>
.el-aside {/*侧边栏*/
  color: #333;
  box-shadow:2px 0 6px rgba(0,21,41,.35);/* 侧边栏阴影 */
  transition: width .3s;
}
.el-menu--inline .el-menu-item {  /*子菜单*/
  background-color: #000c17 !important; ;
  color: #ffffff;
}

.el-menu-item :hover{/* 鼠标移入 */
  color: #fff !important;
}

.link1{/*  子菜单 */
  text-decoration: none;
  color: rgba(255,255,255,0.65);
}
.el-header {/* 头部 */
  box-shadow:2px 0 6px rgba(0,21,41,.35);
  display: flex;
  align-items: center;
}
</style>
